# 计算器：输入两个数和符号，能直接得出此格式的结果(一种更简洁的实现)
from abc import ABC, abstractmethod


class Operation(ABC):
    _a = 0
    _b = 0
    _sbl = ''

    def __init__(self):
        self.numA = self._a
        self.numB = self._b
        self.symbol = self._sbl

    @abstractmethod
    def get_result(self):
        pass


class Vector:

    def __init__(self, a, b):
        self.numA = a
        self.numB = b
        self.result = 0


class VectorAdd(Vector):

    def __init__(self, a, b):
        super(VectorAdd, self).__init__(a, b)
        self.result = self.numA + self.numB


class VectorSub(Vector):

    def __init__(self, a, b):
        super(VectorSub, self).__init__(a, b)
        self.result = self.numA - self.numB


class VectorMul(Vector):

    def __init__(self, a, b):
        super(VectorMul, self).__init__(a, b)
        self.result = self.numA * self.numB


class VectorDiv(Vector):

    def __init__(self, a, b):
        super(VectorDiv, self).__init__(a, b)
        self.result = self.numA / self.numB


class OperationFactory(Operation):

    def _create_vector(self):
        if self.symbol == '+':
            oper = VectorAdd(self.numA, self.numB)
            return oper
        elif self.symbol == '-':
            oper = VectorSub(self.numA, self.numB)
            return oper
        elif self.symbol == '*':
            oper = VectorMul(self.numA, self.numB)
            return oper
        elif self.symbol == '/':
            oper = VectorDiv(self.numA, self.numB)
            return oper

    def get_result(self):
        return "{0} {1} {2} = {3}".format(self.numA, self.symbol, self.numB, self._create_vector().result)


if __name__ == '__main__':
    op = OperationFactory()
    op.numA = 2
    op.numB = 3
    op.symbol = '/'
    print(op.get_result())
